package com.ruoyi.web.controller.swimming;

import java.util.List;

import com.ruoyi.swimming.domian.SwimmingTicketWriteOff;
import com.ruoyi.swimming.service.ISwimmingTicketWriteOffService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 泳池核销流水单Controller
 * 
 * @author ruoyi
 * @date 2021-07-17
 */
@RestController
@RequestMapping("/system/off")
public class SwimmingTicketWriteOffController extends BaseController
{
    @Autowired
    private ISwimmingTicketWriteOffService swimmingTicketWriteOffService;

    /**
     * 查询泳池核销流水单列表
     */
    @PreAuthorize("@ss.hasPermi('system:off:list')")
    @GetMapping("/list")
    public TableDataInfo list(SwimmingTicketWriteOff swimmingTicketWriteOff)
    {
        startPage();
        List<SwimmingTicketWriteOff> list = swimmingTicketWriteOffService.selectSwimmingTicketWriteOffList(swimmingTicketWriteOff);
        return getDataTable(list);
    }

    /**
     * 导出泳池核销流水单列表
     */
    @PreAuthorize("@ss.hasPermi('system:off:export')")
    @Log(title = "泳池核销流水单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SwimmingTicketWriteOff swimmingTicketWriteOff)
    {
        List<SwimmingTicketWriteOff> list = swimmingTicketWriteOffService.selectSwimmingTicketWriteOffList(swimmingTicketWriteOff);
        ExcelUtil<SwimmingTicketWriteOff> util = new ExcelUtil<SwimmingTicketWriteOff>(SwimmingTicketWriteOff.class);
        return util.exportExcel(list, "泳池核销流水单数据");
    }

    /**
     * 获取泳池核销流水单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:off:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(swimmingTicketWriteOffService.selectSwimmingTicketWriteOffById(id));
    }

    /**
     * 新增泳池核销流水单
     */
    @PreAuthorize("@ss.hasPermi('system:off:add')")
    @Log(title = "泳池核销流水单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SwimmingTicketWriteOff swimmingTicketWriteOff)
    {
        return toAjax(swimmingTicketWriteOffService.insertSwimmingTicketWriteOff(swimmingTicketWriteOff));
    }

    /**
     * 修改泳池核销流水单
     */
    @PreAuthorize("@ss.hasPermi('system:off:edit')")
    @Log(title = "泳池核销流水单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SwimmingTicketWriteOff swimmingTicketWriteOff)
    {
        return toAjax(swimmingTicketWriteOffService.updateSwimmingTicketWriteOff(swimmingTicketWriteOff));
    }

    /**
     * 删除泳池核销流水单
     */
    @PreAuthorize("@ss.hasPermi('system:off:remove')")
    @Log(title = "泳池核销流水单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(swimmingTicketWriteOffService.deleteSwimmingTicketWriteOffByIds(ids));
    }
}
